package com.autonavi.yunda.yunji.core.vo.node;

import com.autonavi.yunda.yunji.common.utils.JsonUtils;
import com.autonavi.yunda.yunji.core.enums.NodeType;
import com.autonavi.yunda.yunji.core.vo.EngineFunctionConfigVO;
import com.fasterxml.jackson.core.type.TypeReference;

/**
 * @author cizhong.wcs
 * @date 2022/6/1 20:12
 */
public class GroovyFunctionNode extends BaseNode {
    public String script;
    public String packageName;


    public static GroovyFunctionNode from(EngineFunctionConfigVO vo) {
        GroovyFunctionNode node = new GroovyFunctionNode();
        node.name = vo.getName();
        node.script = vo.getFunctionScript();
        node.nodeType = NodeType.groovy;
        node.params = JsonUtils.from(vo.getParams(), new TypeReference<>() {
        });
        return node;
    }
}
